Skip to content

fix (fileprovider): Consume lock ETags before File Provider content updates - #10641

Open
Rello wants to merge 1 commit into
masterfrom
bugfix/fileproviderfilelock
Open

fix (fileprovider): Consume lock ETags before File Provider content updates#10641
Rello wants to merge 1 commit into
masterfrom
bugfix/fileproviderfilelock

Conversation

@Rello

@Rello Rello commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

Issue

Opening a Microsoft Word document creates a local Word lock file, which causes the File Provider extension to send a WebDAV LOCK request.

The server lock succeeded, but locking also changed the server ETag. The File Provider previously used that ETag for both:

  • metadataVersion
  • contentVersion

A lock-only ETag change therefore appeared to macOS as changed file contents. File Provider attempted to evict or replace the materialized document while Word still had it open, resulting in Resource busy, FP -2008, and a Finder cloud/error icon.

A second case occurred when the document was already locked by the same client. The LOCK response restored the local token but returned the existing ETag. Because the ETag did not change, macOS did not refresh its cached item metadata. The document remained advertised as non-writable and macOS applied the immutable uchg flag.

Fix

The implementation separates server metadata changes from actual file-content changes:

  1. The ETag and token returned by LOCK are written directly to the target item's metadata.

  2. A persisted fileProviderContentVersion retains the version of the file contents already known to File Provider. A lock-only ETag transition changes metadataVersion while leaving contentVersion unchanged. A successful upload advances both to the upload ETag.

  3. After storing the lock token, the target item's synchronization timestamp is updated and the existing working-set change notifier is triggered. This immediately reports the updated lock capabilities to macOS.

  4. The effective lock-ownership state is included in metadataVersion. Recovering a local token therefore refreshes the item even when LOCK returns the same ETag.

  5. Both capabilities and fileSystemFlags recognize a locally owned token lock as writable. This prevents macOS from applying the immutable uchg flag.

A separate File Provider content version is required. Simply updating the ETag would also change contentVersion, causing macOS to treat the lock-only transition as changed file contents and attempt another replacement.

Dependent on nextcloud/NextcloudKit#249

Assisted-by: Codex:GPT-5

@Rello Rello self-assigned this Aug 21, 2026
@Rello Rello added os: 🍎 macOS Apple macOS, formerly also known as OS X feature: 📁 file provider macOS File Provider Extension, more general also known as virtual file system. labels Aug 21, 2026
@Rello Rello changed the title Consume lock ETags before File Provider content updates fix (fileprovider): Consume lock ETags before File Provider content updates Aug 21, 2026
@Rello
Rello marked this pull request as ready for review August 25, 2026 20:05
@i2h3 i2h3 added the bug label Aug 26, 2026
@github-project-automation github-project-automation Bot moved this to 🧭 Planning evaluation (don't pick) in 💻 Desktop Clients team Aug 26, 2026
@i2h3 i2h3 added this to the 34.0.4 milestone Aug 26, 2026
@i2h3 i2h3 moved this from 🧭 Planning evaluation (don't pick) to 🏗️ In progress in 💻 Desktop Clients team Aug 26, 2026

@i2h3 i2h3 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And Nextcloud Desktop Client.xcworkspace/xcshareddata/swiftpm/Package.resolved contains wrong hashes.

Signed-off-by: Rello <github@scherello.de>

Assisted-by: Codex:GPT-5
@Rello
Rello force-pushed the bugfix/fileproviderfilelock branch from 4748fd4 to 0043b2c Compare August 26, 2026 15:56
@github-actions

Copy link
Copy Markdown
Contributor

Artifact containing the AppImage: nextcloud-appimage-pr-10641.zip

Digest: sha256:cbf15bfbb01e95e146532261a73e251348da5a242e5abfbddeea1e3c411dbff9

To test this change/fix you can download the above artifact file, unzip it, and run it.

Please make sure to quit your existing Nextcloud app and backup your data.

@sonarqubecloud

Copy link
Copy Markdown

@Rello

Rello commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator Author

@i2h3 problems are solved. It is building. and the test is confirmed that it is working as expected not.
you need an instance with file locking (not on the company instance)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug feature: 📁 file provider macOS File Provider Extension, more general also known as virtual file system. os: 🍎 macOS Apple macOS, formerly also known as OS X

Projects

Status: 🏗️ In progress

Development

Successfully merging this pull request may close these issues.

2 participants